<%@codepage="65001"%>
<%session.codepage="65001"%>
<!-- #include virtual=/inc/dbConn.asp -->
<!-- #include virtual=/inc/function.asp -->
<!-- #include virtual=/inc/action.header.inc.asp -->

<%
	'## 파라미터 변수 선언부
	compCd		= Request("compCd")
	billCd		= Request("billCd")
	income			= Request("income")
	incomeDt		= Request("incomeDt")
	amount		= Request("amount")
	orgAmount	= Request("orgAmount")
	tax				= Request("tax")
	part				= Request("part")
	billMemo		= Request("billMemo")
	flag				= Request("flag")

	If orgAmount = "" Then orgAmount = "0" End If 
	If tax = "" Then tax = "0" End If 
	If amount = "" Then amount = "0" End If 

	income				= Replace(income,"'","''")
	orgAmount		= Replace(orgAmount,",","")
	tax					= Replace(tax,",","")
	amount			= Replace(amount,",","")
		
	issueId = Request.Cookies("S_uid")
	accountCd = 41
	memo = "거래명세서 수동발급에 의한 생성"
	seq = 0	
	
	if billCd = "" then 
		billCd = aFieldValue("SELECT ISNULL(MAX(billCd),0)+1 FROM tblBizBill")
			
		SQLTitle = "-- ■■■■ 거래명세서 정보 관리 저장 ■■■■"
		SQL = "exec spIncome '" & income & "', '" & incomeDt & "', " & accountCd & ", '" & memo & "', '" & amount & "', '" & orgAmount & "', '" & tax & "', '" & accessId & "', " & seq & ", " & compCd & ", '" & flag & "', " & billCd & ",'" & billMemo & "','" & part & "'"
	else
		SQL = "UPDATE tblIncome SET billMemo='" & billMemo & "' WHERE billCd=" & billCd
	end if 
	If xMode="debug" Then 
		Call showDebug(SQLTitle,SQL) 
	End If 

	DbCon.Execute SQL
	
	tmpLotYr = right(left(date(),4),2)
	tmpLotNo = "9999"
	tmpRank = 1
	tmpLotSubNo = aFieldValue("SELECT ISNULL(MAX(lotSubNo),0)+1 FROM tblBizBill WHERE lotYear='" & tmpLotYr & "' AND lotNo='" & tmpLotNo & "' AND billCd=" & billCd)
	prdNm = "임시 품목"
	goodQty = 1
	unitPrice = 0
	totalPrice = 0
	SQL = "INSERT INTO tblBizBill (billCd, lotYear, lotNo, lotSubNo, rank, compCd, prdCd, prdNm, goodQty, unitPrice, totalPrice, addUserId) " & _
			"	VALUES(" & billCd & ",'" & tmpLotYr & "','" & tmpLotNo & "','" & tmpLotSubNo & "','" & tmpRank & "'," & compCd & ", 0, '" & prdNm & "', " & goodQty & ", " & unitPrice & ", " & totalPrice & ", '" & issueId & "')"
	
	If xMode="debug" Then 
		Call showDebug(SQLTitle,SQL) 
	End If 
	DbCon.Execute SQL

	Call rsWithXML("Save OK!")
%>